package com.dstz.demo.rest.controller;

import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.MaterialsUploadManager;
import com.dstz.demo.core.model.Clclb;
import com.dstz.demo.core.model.FindSupplier;
import com.dstz.demo.core.model.Service;
import com.dstz.demo.core.model.Xmprojectinfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/materials")
public class MaterialsUploadController extends BaseController<Xmprojectinfo> {

    @Autowired
    MaterialsUploadManager materialsUploadManager;

    @Override
    protected String getModelDesc() {
        return "提交要录入的信息";
    }

    //提交物料信息
    @PostMapping("/sub/{id}/{sub}")
    public ResultMsg<String> submitMaterials(@PathVariable("id") List<String> list, @PathVariable("sub") String sub) {
        materialsUploadManager.insertList(list, sub);
        return new ResultMsg<String>("添加成功，请刷新页面后查看");
    }

    //审核通过
    @GetMapping("success/{id}")
    public ResultMsg<String> success(@PathVariable("id") String id) {
        materialsUploadManager.success(id);
        return null;
    }

    //审核不通过
    @GetMapping("fail/{id}/{msg}")
    public ResultMsg<String> fail(@PathVariable("id") String id, @PathVariable("msg") String msg) {
        System.out.println(msg);
        materialsUploadManager.fail(id, msg);
        return null;
    }

    // 查询材料库中的信息
    @GetMapping("selectOne/{id}")
    public List<Clclb> selectOne(@PathVariable("id") String id) {
        List<Clclb> clclbs = materialsUploadManager.selectOne(id);
        return clclbs;
    }

    // 查询服务库中的信息
    @GetMapping("selectlist/{id}")
    public List<Service> selectlist(@PathVariable("id") String id) {
        List<Service> selectlist = materialsUploadManager.selectlist(id);
        return selectlist;
    }

    //查询调查任务的详细信息
    @GetMapping("scdcfpryb/{id}")
    public Map<String, String> scdcfpryb(@PathVariable("id") String id) {
        Map<String, String> scdcfpryb = materialsUploadManager.scdcfpryb(id);
        return scdcfpryb;
    }

    //查询任务中材料的录入信息
    @GetMapping("materialsDetails/{id}")
    public List<FindSupplier> materialsDetails(@PathVariable("id") String id) {
        return materialsUploadManager.materialsDetails(id);
    }

    //查询任务中服务的录入信息
    @GetMapping("serviceDetails/{id}")
    public List<FindSupplier> serviceDetails(@PathVariable("id") String id) {
        return materialsUploadManager.serviceDetails(id);
    }

    @RequestMapping("statistics/{time}")
    public List<Map<String,String>> statistics(@PathVariable("time") String time){
        return materialsUploadManager.statistics(time);
    }
    //改变  材料
    @GetMapping("materialsDetails1/{id}/{clid}")
    public List<FindSupplier> materialsDetails1(@PathVariable("id") String id,@PathVariable("clid") String clid) {
        return materialsUploadManager.materialsDetails1(id,clid);
    }

    //改变 服务
    @GetMapping("serviceDetails1/{id}/{fwid}")
    public List<FindSupplier> serviceDetails1(@PathVariable("id") String id,@PathVariable("fwid") String fwid){
        return materialsUploadManager.serviceDetails1(id,fwid);
    }
    //查询材料录入的结果
    @RequestMapping("findListFindSupplier/{id}/{materialsID}")
    public List<FindSupplier> findListFindSupplier(@PathVariable("id") String id, @PathVariable("materialsID") String materialsID) {
        return materialsUploadManager.findListFindSupplier(id, materialsID);
    }

    //查询服务录入的结果
    @RequestMapping("findServiceListFindSupplier/{id}/{serviceID}")
    public List<FindSupplier> findServiceListFindSupplier(@PathVariable("id") String id, @PathVariable("serviceID") String serviceID) {
        return materialsUploadManager.findServiceListFindSupplier(id, serviceID);
    }


}
